﻿using System;

namespace EasySL.Controls
{
    public class ExStringConverter : ExConverter
    {

        public override object Convert(object value)
        {
            return value.ToString();
        }
    }

    public class ExNumberConverter : ExConverter
    {

        public override object Convert(object value)
        {
            //if (value.GetType() == typeof(double))
            //    return Math.Round((double)value, 2).ToString("F2");
            //else if (value.GetType() == typeof(int))
                    //return System.Convert.ToInt32(value).ToString("#,###");

            //return value.ToString();

            var num = System.Convert.ToInt32(value);
            if (num == 0)
                return num.ToString();
            else
                return num.ToString("#,###");
        }
    }

    public class ExFloatNumberConverter : ExConverter
    {
        public override object Convert(object value)
        {
            var num = Math.Round((double)value, 2).ToString("F2");
            return num;
        }
    }

    public class ExPercentConverter : ExConverter
    {

        public override object Convert(object value)
        {
            string percentage = Math.Round((double)value * 100, 2).ToString();
            percentage += "%";

            return percentage;
        }
    }

    public class ExBoolConverter : ExConverter
    {

        public override object Convert(object value)
        {
            return (bool)value;
        }
    }
}
